/**
 * <p>Title: Oxidy公共包</p>
 * <p>Description: Oxidy公共包</p>
 * <p>Copyright: Copyright (C) 2008-2010</p>
 * <p>Company: [OXIDY.NF.NET/OXIDY.JAVAEYE.COM]</p>
 * 
 * FileName: ForceNoCacheFilter.java
 * Package: net.sf.oxidy.common.filter
 * Description: 用于的使 Browser 不缓存页面的过滤器
 *
 * @author zhangyj
 * @version 2008-11-8 下午03:24:32
 */
package net.sf.oxidy.common.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

/**
 *  用于的使 Browser 不缓存页面的过滤器
 *
 */
public class ForceNoCacheFilter implements Filter {

	/* (non-Javadoc)
	 * @see javax.servlet.Filter#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {

		((HttpServletResponse) response).setHeader("Cache-Control","no-cache");  
		((HttpServletResponse) response).setHeader("Pragma","no-cache");  
		((HttpServletResponse) response).setDateHeader ("Expires", -1);  
		chain.doFilter(request, response);  
	}

	/* (non-Javadoc)
	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
	 */
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub

	}

}
